package com.tensquare.recruit.Controller;

import com.tensquare.recruit.Service.EnterpriseService;
import com.tensquare.recruit.client.RecruitClient;
import com.tensquare.recruit.pojo.Enterprise;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/enterprise")
public class EnterpriseController {
    @Autowired
    private EnterpriseService enterpriseService;

    @Autowired
    private RecruitClient recruitClient;

    @GetMapping("/label/{labelId}")
    public Result findByLabelId(@PathVariable String labelId){
        Result byId = recruitClient.findById(labelId);
        return byId;
    }
    @GetMapping("/search/hotlist")
    public Result hotlist(){
        List<Enterprise> list=enterpriseService.hotList("1");
        return new Result(true, StatusCode.OK,"查询成功",list);
    }

    @GetMapping("/redis")
    public Result get(){
        String s = enterpriseService.redisGet();
        return new Result(true, StatusCode.OK,"查询成功",s);
    }

    @GetMapping("/search/{s}")
    public Result set(@PathVariable String s){
        enterpriseService.redisSet(s);
        return new Result(true, StatusCode.OK,"查询成功");
    }
}
